#include <iostream>
#include <unistd.h>
#include <thread>

void threadrun(std::string name, int num)
{
    while (num)
    {
        std::cout << name << " is running, num: " << num << std::endl;
        --num;
        sleep(1);
    }
}
int main()
{
    std::string name = "thread-1";
    std::thread td1(threadrun, name, 10);

    // 主线程
    while (1)
    {
        std::cout << "main thread run..." << std::endl;
        sleep(1);
    }

    // 等待线程对象
    td1.join();
    return 0;
}